//
// Created by ASUS on 2024/3/19.
//
#include <bits/stdc++.h>
using namespace std;

int _multi_dp(vector<int>& w, vector<int>& v, vector<int>&cnt ,int target){
	int n=w.size();
	vector<vector<int>> f(n+1,vector<int>(target+1,0));
	for(int i=1;i<=n;i++){
		for(int j=target;j>=w[i];j--){
			for(int k=1;k<=cnt[i]&&k*w[i]<=j;k++)
				f[i][j]=max(f[i-1][j],f[i-1][j-k*w[i]]+k*v[i]);
		}
	}
	return f[n][target];
}

int _multi_dp_1(vector<int>& weight, vector<int>& value, vector<int>&cnt ,int target){
	int n=weight.size();
	vector<int> f(target+1,0);
	for(int i=0;i<n;i++){
		for(int j=target;j>=weight[i];j--){
			for(int k=1;k<=cnt[i]&&k*weight[i]<=j;k++)
				f[j]=max(f[j],f[j-k*weight[i]]+k*value[i]);
		}
	}
	return f[target];
}